package com.iris.live.services.data.repositories.impl;

import com.google.common.collect.Maps;
import com.iris.live.services.data.repositories.SalesSetRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Repository
@Transactional
public class SalesSetRepositoryImpl  extends BaseRepository implements SalesSetRepository {

	@Override
	public List getFunctionList(String permit) {
		Map<String, String> params = Maps.newHashMap();
        String sql = "SELECT   \n" +
                "  a.`用户名`,  \n" +
                "  a.`人员姓名`,  \n" +
                "  a.`人员电话`,  \n" +
                "  b.`组名`,  \n" +
                "  IF( a.`职位` = 'C-Sales' or a.`职位` = '正式'  , '正式', '实习') 职位,  \n" +
                "  if( a.接待状态 = '', '', a.`接待状态`) as 接待状态,  \n" +
                "  a.`品牌`,  \n" +
                "  a.`销售顾问头像路径`,  \n" +
                "  '0' 状态,  \n" +
                "  a.superior,  \n" +
				"	a.销售顾问职位状态 " +
                "FROM `用户` AS a   \n" +
                "LEFT JOIN `销售顾问分组` AS b ON a.`许可` = b.`许可` AND a.`用户名` = b.`销售顾问`   \n" +
                "WHERE a.`许可` = :permit   \n" +
                "AND a.`角色` = '销售顾问'   \n" +
                "AND IFNULL(`删除状态`, '') <> '已删除'   \n";
        params.put("permit", permit);
		return this.getList(sql, params);
	}

	@Override
	public List getBrand() {
		Map<String, String> params = Maps.newHashMap();
		String sql=" SELECT DISTINCT(品牌) 品牌 FROM `LSH车型` WHERE `品牌`<> '' ";
		return this.getList(sql);
	}


	@Override
	public List getSaletype() {
		Map<String, String> params = Maps.newHashMap();
		String sql=" SELECT sale_type from sale_type ";
		return this.getList(sql);
	}

}
